
let PROTO_PATH = __dirname + '/../go-add/proto/add.proto'
let grpc = require('@grpc/grpc-js')
let protoLoader = require('@grpc/proto-loader')

let packageDefinition = protoLoader.loadSync(
  PROTO_PATH,
  {
    keepCase: true,
    longs: String,
    enums: String,
    defaults: true,
    oneofs: true,
  },
)
let add = grpc.loadPackageDefinition(packageDefinition).add
let client = new add.Add(
  'localhost:50051',
  grpc.credentials.createInsecure(),
)

let a = parseInt(process.argv[2])
let b = parseInt(process.argv[3])

client.Add(
  {a, b},
  (err, r) => {
    if (err === null)
      console.log(r.message)
    else
      console.log(err)
  },
)

